package com.example.chapter10;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class Demo7 {
    public static void main(String[] args) {
        List<String> names = Arrays.asList("张三", "李四", "王五");
        Iterator<String> iterator = names.iterator();
        while (iterator.hasNext()) {
            String name = iterator.next();
            System.out.println(name);
        }

        for (String name : names) {
            System.out.println(name);
        }

        names.stream().forEach(name -> System.out.println(name));

        names.forEach(System.out::println);
    }
}
